<link type="text/css" rel="stylesheet" href="{url:#css/ucenter.css}" />
{echo:JS::import('form');}
{echo:JS::import('date');}
{echo:JS::import('dialog?skin=tinysimple');}
<script type="text/javascript" charset="UTF-8" src="{url:#js/jquery.iframe-post-form.js}"></script>
<div class="container clearfix">
	{widget:name=sub_navs action=ucsidebar sidebar=$sidebar act=$actionId}
	<div class="content clearfix uc-content">
		<h1 class="title"><span>注册会员：</span></h1>
		<!-- 
		<span>推广连接：<a target="blank" href="{url:/simple/reg/num/$user[number]}">
			http://www.ahcysc.com/index.php?con=simple&act=reg&num={$user[number]} 
			</a><label style="font-size:12px;">(右键复制链接地址)</label>
			</span>
			<br>
			<span>
				{set:$url=urlencode(Common::get_complete_path("/simple/reg/num/$user[number]"))}
				<img src="{url:/simple/get_qrcode_img_by_url/url/$url}"/>
			</span>
		-->	
		
		{if:isset($msg)}
		<div class="message_{$msg[0]} ie6png">{$msg[1]}</div>
		{elseif:isset($validator)}
		<div class="message_warning ie6png">{$validator['msg']}</div>
		{/if}
		
		<table border="0">
			<tr>
				<td>
					分享连接：<a target="blank" href="{url:/simple/reg/num/$user[number]}">
			http://www.ahcysc.com/index.php?con=simple&act=reg&num={$user[number]} 
			</a><label style="font-size:12px;">(右键复制链接地址)</label>
				</td>
			</tr>
			<tr>
				<td>
					{set:$url=urlencode(Common::get_complete_path("/simple/reg/num/$user[number]"))}
					<img src="{url:/simple/get_qrcode_img_by_url/url/$url}"/>
				</td>
			</tr>
			<tr>
				<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>扫一扫 二维码</span></td>
			</tr>
		</table>		
			
		
		<div class="mt10" style="position:relative;margin-left:140px;margin-top:-200px;">
			
			<form id="info-form" class="simple" action="{url:/ucenter/reg_act}" method="post">
				<table class="form">
					<!-- <tr><td class="label">会员帐号：</td><td>{if:Validator::match('\d+@no.com',$info['email'])}<input type="text" pattern="email" name="email" value="{$email}" alt="邮箱格式错误"> <label></label>{else:}{$email}{/if}</td></tr> -->
					<!-- <tr><td class="label">会员级别：</td><td>{$gname|'默认分组'}</td></tr> -->
					<tr>
						<td class="label">手机号码：</td><td>
						<input type="text" pattern="((1[3-9]\d{9})|(\d{14}))" id="uname" name="uname"  value="" alt="手机号码不能为空或不合法">
						</td>
					</tr>
					<tr>
						<td class="label">推荐编码：</td><td>
						<input type="text" pattern="required" name="number" id="number" value="{$user['number']}" alt="推荐编码不能为空">
						</td>
					</tr>
					<tr>
						<td class="label">登录密码：</td><td><input placeholder='6-20位字母数字组合' type="password" pattern="required" id="password" name="password" minlen="6" maxlen="20" value="" alt="密码长度为6-20位"> <label></label></td>
					</tr>
					<tr>
						<td class="label">交易密码：</td><td><input placeholder='6-20位字母数字组合' type="password" pattern="required" name="passwordtwo" id="passwordtwo" minlen="6" maxlen="20" value="" alt="密码长度为6-20位"> <label></label></td>
					</tr>
					<tr>
						<td class="label">短信验证码：</td>
						<td>
							{if:Validator::mobi($info['mobile'])}{$mobile}{else:}
							<input type="text" pattern="\d{6}" name="validate_code" id="validate_code" value="" alt="短信验证码为6为数字"><label></label>{/if}
							<input type="button" value="获取短信验证码" class="btn btn-main" onclick="get_validate_code()"/>
						</td>
					</tr>
					
					<tr>
						<td colspan="2" class="tc"><input type="submit" class="btn btn-main" value="提交"></td>
					</tr>
				</table>
				{token:key=reg}
			</form>
		</div>
	</div>
</div>
<div id="head-dialog" style="display: none">
	<div class="box" style="width:400px;">
		<h2>上传头像：</h2>
		<div class="content mt20 p10">
			<form enctype="multipart/form-data" action="{url:/ucenter/upload_head}" method="post"  id="uploadForm">
				<p><input type="file" name="imgFile" ></p>
				<p class="mt20 tc"><button class="btn" id="upload-btn">上传</button></p>
			</form>
		</div>
	</div>
</div>
<script type="text/javascript">
	$("#upload-link").on("click",function (){
		art.dialog({id:'head-dialog',content:document.getElementById('head-dialog'),lock:true});
	});

	$("#uploadForm").iframePostForm({
		iframeID: 'iframe-post-form',
		json:true,
		post: function(){
			$("#upload-btn").text("上传中...")
		},
		complete: function(data){
			if(data['error']==1){
				alert(data['message']);
			}else{
				var root_url = "{url:@}"
				$("#head-pic").attr("src",root_url+data['url']+'?i='+Math.random());
				art.dialog({id:'head-dialog'}).close();
			}
			$("#upload-btn").text("上传");
		}

	});

	var form =  new Form('info-form');
	form.setValue('is_default','{$is_default}');
	$("#areas").Linkage({ url:"{url:/ajax/area_data}",selected:[{$province|0},{$city|0},{$county|0}],callback:function(data){
		var text = new Array();
		var value = new Array();
		for(i in data[0]){
			if(data[0][i]!=0){
				text.push(data[1][i]);
				value.push(data[0][i]);
			}
		}
		$("#test").val(value.join(','));
		FireEvent(document.getElementById("test"),"change");
	}});
	{if:isset($invalid)}
	autoValidate.showMsg({id:$("input[name='{$invalid['name']}']").get(0),error:true,msg:'{$invalid['msg']}'});
	
	{/if}
	
	
		function get_validate_code()
		{
			var mobile = $.trim($("#uname").val());
			if(mobile == '')
			{
				alert('手机号码不能为空');
				return;
			}
			var mobile_pattern = /^((1[3-9]\d{9})|(\d{14}))$/;
			if(!mobile_pattern.test(mobile))
			{
				alert('手机号码不合法');
				return;
			}
			
			$("#btn_get_validate").attr("disabled", true);
			$.post("{url:/simple/sms_send}",{mobile:mobile},function(result){
			      alert(result);
			      $("#btn_get_validate").attr("disabled", false);
			  });
		}
	
</script>
